package dataMining.DynamicTable;

import java.io.IOException;
import java.util.Date;

/**
 * @author: cuiH
 * Date: 13-8-18
 * 通过动态table的方式挖掘top_k频繁项集
 */
public class Top_K {
    public static int K = 100;                          //top_K中K的声明
    public static int tranNumber = 8124;                //定义总的transaction个数
    public static int itemNumber = 120;                 //定义总的item个数
    public static boolean[][] DATA = new boolean[K ][tranNumber+1];             //最终数据集的存储 ，为了处理方便，第一个列位置（0）不存储，和事务数正好对应
    /*
    * 与数据集对应的控制表的声明（K个一一对应）
    * 包括sup(0),prev(2),next(3),skip(4) 四个数据表格
    * */
    public static int[][] controller = new int[K][4];
    public static boolean [][] item = new boolean[K][itemNumber+1];              //依然对应 ，此处存放item，采用boolean的方式，注意适合稠密矩阵

    public static String inputFile = "C:/Users/freedom/IdeaProjects/dataMining/src/mushroom1.dat";
    public static String outputFile = "C:/Users/freedom/IdeaProjects/dataMining/src/DynamicTable/1.0版TOP" + (K - 1) + "项集输出.txt";

    public static void main(String[] args) throws IOException {
        //boolean表的初始化，防止出现exception
        for (int i = 0; i < K ; i++) {
            for (int j = 0; j < tranNumber+1; j++) {
                DATA[i][j] = false;
            }
        }
        //初始化controller
        for (int i = 0; i < K ; i++) {
            for (int j = 0; j < 4; j++) {
                controller[i][j] = 0;
            }
        }
        //初始化item
        for (int i = 0; i < K ; i++) {
            for (int j = 0; j < itemNumber+1; j++) {
                item[i][j] = false;
            }
        }

        //对存放data的boolean表进行填充和对应的控制表进行填充
//        PreProcess preProcess = new PreProcess();
//        preProcess.preProcess();
        PreProcessAbove preProcessAbove = new PreProcessAbove();
        preProcessAbove.preProcess();

        long costTime;
        Date startDate = new Date();                 //开始记录时间

//        //调用算法，具体实施
//        Algorithm algorithm = new Algorithm();
//        algorithm.algorithm();

        Date endDate = new Date();                   //结束时间
        costTime = endDate.getTime() - startDate.getTime();
        System.out.println("所消耗时间为：" + costTime + "ms");
    }
}

